/* 웹폰트(Noto Serif KR, Noto Sans KR)는 PHP가 <link>로 불러옵니다. (quote.lib.php의 quote_add_fonts) */

/* ==========================================================
   문구 모음 스킨
   색과 글꼴은 아래 변수만 바꿔도 전체에 반영됩니다.
   카드마다 --h(색조)가 분류 이름에 따라 자동으로 정해집니다.
   ========================================================== */
.qt {
    --serif: 'Noto Serif KR', 'Nanum Myeongjo', serif;
    --ink: #1f2933;
    --muted: #66727f;
    --line: #d5dbe1;
    --bg: #e9edf0;
    --card: #ffffff;
    --col-gap: 26px;         /* 카드 사이 가로 간격 */
    --card-scale: 1;         /* 글씨, 여백을 카드 크기에 비례시키는 배율. 340px 카드가 1, 400px 카드는 약 1.18 (PHP가 설정값으로 채움) */
    --card-size: 340px;      /* 카드 한 변의 길이. 목록, 상세, 미리보기가 모두 이 크기입니다. */
    --accent: #4a5561;
    --accent-dark: #1f2933;

    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    box-sizing: border-box;
    width: 100%;
    margin-left: auto;      /* 게시판 너비를 줄이면 가운데에 놓임 */
    margin-right: auto;
    padding: 28px;
    background: var(--bg);
    /* 글자색은 지정하지 않음: 사이트의 글자색을 그대로 따릅니다. */
}
.qt *, .qt *::before, .qt *::after { box-sizing: border-box; }

/* 목록, 상세, 글쓰기 컨테이너는 투명: 사이트 배경이 그대로 보입니다. */
.qt-list,
.qt-view,
.qt-write { background: transparent; }

/* ---------- 공통 버튼 ---------- */
.qt-btn {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: var(--card);
    color: var(--ink);
    font-size: 0.875rem;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.qt-btn, .qt-reveal, .qt-cardlink, .qt-swatch { touch-action: manipulation; }
.qt-btn-main { background: var(--ink); border-color: var(--ink); color: #fff; }
.qt a:focus-visible, .qt button:focus-visible,
.qt input:focus-visible, .qt select:focus-visible, .qt textarea:focus-visible {
    outline: 2px solid var(--accent-dark);
    outline-offset: 2px;
}

/* ---------- 목록: 머리말 ---------- */
.qt-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.qt-title h2 { margin: 0; font: 700 1.6rem/1.3 var(--serif); }
.qt-count { margin: 4px 0 0; color: var(--muted); font-size: 0.875rem; }
.qt-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.qt-search { display: flex; gap: 6px; }
.qt-search select, .qt-search input[type=text] {
    color: var(--ink);
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: var(--card);
    font-size: 0.875rem;
}
.qt-search input[type=text] { width: 150px; }

/* ---------- 목록: 분류 ---------- */
.qt-cate { margin-bottom: 22px; }
.qt-cate ul { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; padding: 0; list-style: none; }
.qt-cate a {
    display: block;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: none;
}
.qt-cate #bo_cate_on { color: inherit; font-weight: 700; border-bottom-color: currentColor; }

/* ==========================================================
   발췌 카드 (목록의 .qt-face, 상세의 .qt-paper)
   정사각형, 왼쪽 정렬, 문구 바로 아래에 제목(출처)을 작게.
   카드는 늘어나지 않으며, 글씨가 안 들어가면 자바스크립트가 줄여 맞춥니다.
   ========================================================== */
/* 카드 폭은 줄이지 않습니다. 화면보다 넓어지면 목록 영역이 옆으로 스크롤됩니다. */
.qt-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.qt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, var(--card-size));
    justify-content: center;
    min-width: var(--card-size);
    gap: 30px var(--col-gap);
}
/* 게시판 관리의 "갤러리 이미지 수"를 그대로 지킴: 화면에 안 들어가도 그 열 수로 놓고, 넘치면 옆으로 스크롤 */
.qt-grid.is-cols {
    grid-template-columns: repeat(var(--cols), var(--card-size));
    width: max-content;
    margin-left: auto;
    margin-right: auto;
}
.qt-card { position: relative; display: flex; flex-direction: column; min-width: 0; }

.qt-face,
.qt-paper {
    /* 기본은 흰 카드. 글쓰기에서 배경색을 고르면 style 속성으로 아래 값들이 덮어씌워집니다. */
    --cbg: #ffffff;
    --cfg: #1f2933;
    --csub: rgba(31, 41, 51, .72);

    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--cbg);
    border-radius: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
    font-family: var(--serif);
    text-align: left;
    min-width: 0;
    min-height: 0;
    overflow: hidden;       /* 카드는 늘어나지 않고 정사각형을 지킵니다 (글씨는 자바스크립트가 줄여 맞춤) */
}
.qt-face {
    flex: none;
    aspect-ratio: 1 / 1;
    padding: calc(40px * var(--card-scale, 1)) calc(32px * var(--card-scale, 1));
}

/* 글 보기(상세)에서 8pt로도 안 들어가는 아주 긴 문구: 정사각형을 풀고 카드를 아래로 늘려 전체를 보여줌 */
.qt-paper[data-grow] {
    aspect-ratio: auto;
    min-height: var(--card-size);
    overflow: visible;
    justify-content: flex-start;
}

/* 목록, 미리보기에서 8pt로도 안 들어가는 아주 긴 문구: 문구는 위에서부터 보여주고 아래쪽을 흐리게 잘라내며,
   출처는 항상 카드 맨 아래에 고정되어 가려지지 않습니다. */
.qt-face[data-clip], .qt-paper[data-clip] { justify-content: flex-start; }
.qt-face[data-clip] .qt-body,
.qt-paper[data-clip] .qt-body {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px * var(--card-scale, 1)), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 28px * var(--card-scale, 1)), transparent);
}
.qt-face[data-clip] .qt-meta,
.qt-paper[data-clip] .qt-meta { flex: none; }

/* 문구 */
.qt .qt-text,
.qt .qt-quote {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    quotes: none;
    text-indent: 0;
    text-align: left;
    font-style: normal;
    color: var(--cfg);
    font-family: var(--serif);
    word-break: keep-all;
    overflow-wrap: break-word;
    overflow-wrap: anywhere;
}
/* 사이트 테마가 blockquote 앞뒤에 따옴표 같은 장식을 붙이는 경우를 막습니다. */
.qt .qt-text::before, .qt .qt-text::after,
.qt .qt-quote::before, .qt .qt-quote::after { content: none; display: none; }

.qt-card.is-short .qt-text { font-size: calc(1.45rem * var(--fs, 1) * var(--card-scale, 1)); line-height: 1.7; }
.qt-card.is-mid   .qt-text { font-size: calc(1.1rem * var(--fs, 1) * var(--card-scale, 1));  line-height: 1.95; }
.qt-card.is-long  .qt-text { font-size: calc(0.98rem * var(--fs, 1) * var(--card-scale, 1)); line-height: 2; }

/* 제목(출처)은 문구 바로 아래에 작게 */
.qt .qt-meta { margin: calc(22px * var(--card-scale, 1)) 0 0; padding: 0; text-indent: 0; text-align: left; color: var(--csub); line-height: 1.6; }
.qt .qt-source { display: block; margin: 0; padding: 0; font-size: calc(0.76rem * var(--card-scale, 1)); font-style: normal; font-weight: 400; }

/* 글씨체: 고딕을 고른 카드에만 클래스가 붙습니다. 없으면 바탕(노토 세리프). */
.qt .ff-gothic .qt-text,
.qt .ff-gothic .qt-quote,
.qt .ff-gothic .qt-meta { font-family: 'Noto Sans KR', 'Pretendard', 'Malgun Gothic', sans-serif; }

/* 배경 이미지가 있는 카드: 어둡게 덮고 흰 글씨 */
.qt-face.has-img,
.qt-paper.has-img {
    --cfg: #ffffff;
    --csub: rgba(255, 255, 255, .78);
    background:
        linear-gradient(rgba(14, 16, 30, .45), rgba(14, 16, 30, .6)),
        var(--cimg) center / cover no-repeat,
        #23262f;
}
.qt .has-img .qt-text,
.qt .has-img .qt-quote { text-shadow: 0 1px 10px rgba(0, 0, 0, .35); }

/* 카드 어디를 눌러도 상세 보기로 이동 (스포일러 덮개와 체크박스는 링크 위에 있음) */
.qt-cardlink { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 1; -webkit-tap-highlight-color: rgba(0, 0, 0, .08); }
.qt-cardlink:focus-visible { outline-offset: -4px; }

.qt-tag { margin: 0; color: var(--accent-dark); font-weight: 700; }
.qt-copy,
.qt-save {
    padding: 2px 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.qt-copy.is-done { color: var(--accent-dark); }
.qt-save:disabled { opacity: .6; cursor: wait; }
.qt-empty {
    padding: 80px 20px;
    text-align: center;
    color: var(--muted);
    background: var(--card);
    border: 1px dashed var(--line);
}
.qt-empty p { margin: 4px 0; }


/* ---------- 스포일러 ---------- */
/* 닫힌 상태: 카드 배경은 그대로 두고, 문구만 흐리게 가립니다. 제목(출처)은 보입니다. */
.qt .is-spoiler .qt-blur { transition: filter .25s, opacity .25s; }
.qt .is-spoiler:not(.is-open) .qt-blur {
    filter: blur(calc(30px * var(--card-scale, 1)));
    -webkit-filter: blur(calc(30px * var(--card-scale, 1)));
    opacity: .7;
    user-select: none;
    pointer-events: none;
}

/* 흐린 문구 위의 "스포일러" 버튼: 어떤 배경색, 이미지 위에서도 읽히게 어두운 알약 모양 */
.qt .qt-reveal {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(2px, calc(12px * var(--card-scale, 1)));
    border: 0;
    background: transparent;
    cursor: pointer;
}
.qt .qt-reveal span {
    padding: max(3px, calc(8px * var(--card-scale, 1))) max(6px, calc(16px * var(--card-scale, 1)));
    border-radius: 999px;
    background: rgba(20, 22, 30, .78);
    color: #fff;
    font-size: max(0.4rem, calc(0.85rem * var(--card-scale, 1)));   /* 카드 크기에 비례, 아주 작은 카드에서도 카드 안에 들어가도록 최소값 */
    white-space: nowrap;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
}
.qt .is-spoiler.is-open .qt-reveal { display: none; }

/* ---------- 페이지 번호 ---------- */
.qt .pg_wrap { margin-top: 24px; text-align: center; float: none; }
.qt .pg { display: inline-flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.qt .pg a, .qt .pg strong {
    display: inline-block;
    min-width: 34px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    font-size: 0.85rem;
    text-align: center;
    text-decoration: none;
}
.qt .pg strong.pg_current { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- 상세 보기 ---------- */
.qt-view { padding-top: 40px; padding-bottom: 40px; overflow-x: auto; }
.qt-paper {
    width: var(--card-size);
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    padding: calc(40px * var(--card-scale, 1)) calc(32px * var(--card-scale, 1));
}
.qt-paper .qt-tag { margin: 0 0 calc(12px * var(--card-scale, 1)); color: var(--csub); font-size: calc(0.8rem * var(--card-scale, 1)); }
.qt-paper.is-short .qt-quote { font-size: calc(1.45rem * var(--fs, 1) * var(--card-scale, 1)); line-height: 1.7; }
.qt-paper.is-mid   .qt-quote { font-size: calc(1.1rem * var(--fs, 1) * var(--card-scale, 1));  line-height: 1.95; }
.qt-paper.is-long  .qt-quote { font-size: calc(0.98rem * var(--fs, 1) * var(--card-scale, 1)); line-height: 2; }
.qt-info {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 16px;
    color: var(--muted);
    font-size: 0.8rem;
}

.qt-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 18px 0 32px; }
.qt-actions .qt-copy, .qt-actions .qt-save { padding: 8px 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; }


.qt-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    max-width: 720px;
    margin: 0 auto;
}
.qt-bottom-right { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 글쓰기 ---------- */
.qt-write { padding-top: 32px; padding-bottom: 40px; overflow-x: auto; }
.qt-write form { max-width: 720px; margin: 0 auto; }
.qt-write-title { max-width: 720px; margin: 0 auto 20px; font: 700 1.4rem/1.3 var(--serif); }
.qt-field { margin-bottom: 18px; }
.qt-field label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 700; }
.qt-field input[type=text], .qt-field input[type=number], .qt-field select, .qt-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: var(--card);
    color: var(--ink);
    font: inherit;
}
.qt-field textarea { font-family: var(--serif); font-size: 1.1rem; line-height: 1.8; resize: vertical; }
/* 글씨체를 "고딕"으로 고르면 문구 입력칸도 고딕으로 */
.qt-field textarea.qt-ta-gothic { font-family: 'Noto Sans KR', 'Pretendard', 'Malgun Gothic', sans-serif; }
.qt-check-inline { display: block; margin-bottom: 18px; font-size: 0.9rem; }
.qt-hint { margin: 6px 0 0; color: var(--muted); font-size: 0.8rem; }
.qt-write .qt-bottom { margin-top: 8px; }

/* 카드 배경색 고르기 */
.qt-colors { min-width: 0; padding: 0; border: 0; }
.qt-colors legend { margin-bottom: 8px; padding: 0; font-size: 0.9rem; font-weight: 700; }
.qt-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.qt-swatch { position: relative; display: block; margin: 0; cursor: pointer; }
.qt-field .qt-swatch { display: block; margin: 0; font-weight: 400; }
.qt-swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.qt-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 2px;
}
.qt-chip-text { width: auto; padding: 0 12px; background: var(--card); font-size: 0.82rem; color: var(--ink); }
.qt-swatch input:checked + .qt-chip { outline: 2px solid var(--ink); outline-offset: 2px; }
.qt-swatch input:focus-visible + .qt-chip { outline: 2px solid var(--accent-dark); outline-offset: 2px; }
#wr_4_picker { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); background: none; cursor: pointer; }

/* 미리보기 카드 */
.qt-preview {
    flex: none;
    aspect-ratio: 1 / 1;
    width: var(--card-size);
    margin-top: 16px;
}
.qt-preview .qt-meta[hidden] { display: none; }

/* 미리보기도 실제 카드와 똑같이 문구 길이(짧음/보통/긺)에 따라 같은 크기, 줄 간격을 씁니다. */
.qt-preview.is-short .qt-text { font-size: calc(1.45rem * var(--fs, 1) * var(--card-scale, 1)); line-height: 1.7; }
.qt-preview.is-mid   .qt-text { font-size: calc(1.1rem * var(--fs, 1) * var(--card-scale, 1));  line-height: 1.95; }
.qt-preview.is-long  .qt-text { font-size: calc(0.98rem * var(--fs, 1) * var(--card-scale, 1)); line-height: 2; }

/* ---------- 마우스가 있는 기기에서만 hover 효과 ---------- */
@media (hover: hover) {
    .qt-btn:hover { border-color: var(--ink); }
    .qt-btn-main:hover { background: #000; }
    .qt-cate a:hover { color: inherit; }
    .qt-copy:hover, .qt-save:hover { color: var(--accent-dark); }
    .qt .qt-reveal:hover span { background: rgba(0, 0, 0, .92); }
    .qt-actions .qt-copy:hover, .qt-actions .qt-save:hover { border-color: var(--ink); color: var(--ink); }
}

/* ---------- 모바일 ---------- */
@media (max-width: 600px) {
    .qt { padding: 16px 14px; }

    /* 머리말: 제목 아래에 도구가 한 줄씩 */
    .qt-head { align-items: stretch; margin-bottom: 14px; }
    .qt-tools { width: 100%; }
    .qt-search { flex: 1 1 100%; width: 100%; }
    .qt-search select { flex: 0 0 auto; }
    .qt-search input[type=text] { flex: 1; min-width: 0; width: auto; }

    /* 버튼은 작고 단정하게, 그래도 손가락으로 누를 수 있는 크기(약 36px) */
    .qt-btn { min-height: 34px; padding: 7px 12px; font-size: 0.82rem; }
    .qt-search select, .qt-search input[type=text] { height: 38px; }
    .qt-chip { width: 36px; height: 36px; }
    .qt-chip-text { width: auto; min-width: 36px; padding: 0 12px; font-size: 0.85rem; white-space: nowrap; }
    #wr_4_picker { width: 36px; height: 36px; }
    .qt-check-inline { padding: 6px 0; font-size: 0.9rem; }
    .qt-check-inline input { width: 18px; height: 18px; margin-right: 6px; vertical-align: middle; }

    /* 입력창은 16px 이상이어야 iOS가 화면을 확대하지 않습니다. */
    .qt-search select, .qt-search input[type=text],
    .qt-field input[type=text], .qt-field input[type=number],
    .qt-field select, .qt-field textarea { font-size: 16px; }
    .qt-field input[type=text], .qt-field input[type=number], .qt-field select { min-height: 40px; }

    /* 분류: 한 줄로 옆으로 밀어서 보기 */
    .qt-cate { margin: 0 -14px 16px; padding: 0 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .qt-cate { scrollbar-width: none; }
    .qt-cate::-webkit-scrollbar { display: none; }
    .qt-cate ul { flex-wrap: nowrap; gap: 18px; }
    .qt-cate li { flex: 0 0 auto; }
    .qt-cate a { padding: 8px 0; white-space: nowrap; }

    /* 카드: 폰에서는 열 수 설정과 상관없이 한 줄에 한 장씩 아래로 쌓고,
       카드가 화면 폭을 넘지 않게 맞춥니다. (좌우 스크롤 없이 위아래로만 스크롤) */
    .qt-grid, .qt-grid.is-cols { grid-template-columns: minmax(0, var(--card-size)); width: auto; min-width: 0; gap: 20px; }
    .qt-paper { width: min(var(--card-size), 100%); }
    .qt-preview { width: min(var(--card-size), 100%); }

    /* 상세 */
    .qt-view { padding-top: 20px; padding-bottom: 24px; }
    .qt-actions { gap: 6px; margin: 14px 0 20px; }
    .qt-actions .qt-btn { flex: 0 0 auto; }
    .qt-bottom { justify-content: flex-start; gap: 6px; }
    .qt-bottom-right { width: auto; gap: 6px; }

    /* 글쓰기 */
    .qt-write { padding-top: 20px; padding-bottom: 24px; }
    .qt-write .qt-bottom .qt-btn { flex: 1 1 0; text-align: center; }

    /* 페이지 번호 */
    .qt .pg a, .qt .pg strong { min-width: 34px; padding: 8px 6px; }
}

@media (prefers-reduced-motion: reduce) {
    .qt-btn, .qt .is-spoiler .qt-blur { transition: none; }
}
